<!DOCTYPE html>
<html>
<head>
    <title>京山市人民医院-OA系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        body, html {
            margin: 0;
            padding: 0;
            font-family: Lato, Helvetica, Arial, sans-serif;
            font-size: 14px;
            line-height: 1.72222;
            color: #34495e;
            background-color: #fff;
            height: 100%;
            width: 100%;
        }

        .shadow {
            position: fixed;
            z-index: 10000;
            width: 200px;
            height: 200px;
            top: 0;
            left: 0;
            right: 0;
            bottom: 0;
            margin: auto;
        }
        .div_cla{
            width: 100%;height: 40px;background: #F0F0F0;line-height: 40px;padding-left: 2%;margin-top: 1%;
        }
        th{
            border: white 1px solid;
            background: #c8cbcf;
        }
        #table td{
            height: 35px;
            cursor: pointer;
        }
        #table tr:hover{
            background: #D8D8D8;
            color: white;
        }
    </style>
</head>
<body>
    <div id="wrap" class="wrap" style="height: 100%;width: 100%;">
        <table style="border-collapse: collapse;width: 100%;table-layout: fixed;">
            <thead>
                <tr>
                    <th style="width: 10%;height: 35px;">序号</th>
                    <th style="width: 50%;height: 35px;">文件名</th>
                    <th style="width: 25%;height: 35px;">创建时间</th>
                    <th style="width: 15%;height: 35px;">操作</th>
                </tr>
            </thead>
            <tbody id="table">
                {% for file in file_list %}
                    <tr>
                        <td style="width: 10%;border: #D8D8D8 solid 1px;">{{ file.serial }}</td>
                        <td style="width: 50%;text-align: center;border: #D8D8D8 solid 1px;">{{ file.file_name }}</td>
                        <td style="width: 25%;text-align: center;border: #D8D8D8 solid 1px;">{{ file.create_time }}</td>
                        <td style="width: 10%;border: #D8D8D8 solid 1px;"><a href="{{ file.file_path }}">下载</a> |
                            <a href="#" onclick="delete_file('{{ file.file_path }}')">删除</a></td>
                    </tr>
                {% endfor %}
            </tbody>
        </table>
    </div>

    <script>
        function delete_file(file_path) {
            var xhr = new XMLHttpRequest();
            var local_host = window.location.host;          // 获取当前IP
            xhr.open('post', "/administrative/view-model", true);
            xhr.setRequestHeader('content-type', 'application/x-www-form-urlencoded');
            xhr.send("file_path="+String(file_path));
            xhr.onreadystatechange = function () {
                if (xhr.readyState === 4) {
                    if (xhr.status === 200) {
                        var JsonDate = JSON.parse(xhr.responseText);
                        window.location.reload();
                    }
                }
            };
        }
    </script>
</body>
</html>
